# Maintainer: David Runge <dvzrv@archlinux.org>

_name=myMPD
pkgname=mympd
pkgver=10.3.1
pkgrel=1
pkgdesc="A standalone and lightweight web-based MPD client"
arch=(loong64 x86_64)
url="https://github.com/jcorporation/myMPD"
license=(GPL3)
depends=(
  glibc
  lua
)
makedepends=(
  cmake
  flac
  jq
  libid3tag
  openssl
  pcre2
  perl
)
source=(https://github.com/jcorporation/$pkgname/archive/v$pkgver/$pkgname-v$pkgver.tar.gz)
sha512sums=('c6e9019d76da3577a94610b4f4866b8beb092d241885003eab5216df6fd3d01612448b5afe9d403ee91936fe0af032ec6585afe4c3263a789b7aefba4517aa84')
b2sums=('b0e2eb111ad1123200f86ad7ef1a6c302fcd0c2414006bc24970d045ae51ee302c68521974868ef0c14f5d259e8344206509ee05cce3bc10c51b68943d9478a9')

build() {
  local cmake_options=(
    -B build
    -DCMAKE_BUILD_TYPE=None
    -DCMAKE_INSTALL_PREFIX=/usr
    -DENABLE_FLAC=ON
    -S $_name-$pkgver
    -Wno-dev
  )

  cmake "${cmake_options[@]}"
  cmake --build build --verbose
}

check() {
  ctest --test-dir build --output-on-failure
}

package() {
  depends+=(
    flac libFLAC.so
    libid3tag libid3tag.so
    openssl libssl.so
    pcre2 libpcre2-8.so
  )

  DESTDIR="$pkgdir" cmake --install build
  install -vDm 644 $_name-$pkgver/{CHANGELOG,README}.md -t "$pkgdir/usr/share/doc/$pkgname/"
}
